package www.albertzhe;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import www.albertzhe.manager.http.HttpResult;
import www.albertzhe.manager.http.iamp.IampRequest;

@SpringBootApplication
@RestController
public class IndexApplication {

	public static void main(String[] args) {
		SpringApplication.run(IndexApplication.class, args);
	}
	
	
	
	
	
	
	@Autowired
	private IampRequest iampRequest;
	
	@GetMapping("/hello")
	public String hello() throws DocumentException {
	    HttpResult logon = iampRequest.logon("ylp2", "9q1hp984FWdsjPku");
        if (!logon.isFlag()) {
            return "wrong";
        }
        String teString = logon.getContent();
        
        Document document2 = DocumentHelper.parseText(teString);
        
        System.out.println(document2.selectSingleNode("/xml/session/key").getText());
        System.out.println(document2.selectSingleNode("/xml/session/expired").getText());
        
        return teString;
	}
}
